import {getDefaultConfig, View} from "@web/views/view";
import {mount, nextTick} from "../../tests/helpers/utils";


export function makeView(params, target, env = {}) {
    const props = {...params};

    const config = {
        ...getDefaultConfig(),
    

    };

    // delete props.config;

    if (props.arch) {

        props.viewId = params.viewId || 100000001; // hopefully will not conflict with an id already in views

        props.searchViewId = params.searchViewId || 100000002; // hopefully will not conflict with an id already in views
        const searchViewArch = props.searchViewArch || "<search/>";

        // delete props.searchViewArch;
    }
    console.log(props)
    // const view = await mount(View, target, {env: env, props});
    // await nextTick();
    // const viewNode = view.__owl__;
    //
    // const withSearchNode = Object.values(viewNode.children)[0];
    // const concreteViewNode = Object.values(withSearchNode.children)[0];
    // const concreteView = concreteViewNode.component;

    // return concreteView;
    const viewEnv = Object.assign({}, {config})

    return {props, viewEnv}

}
